package com.awesome.videodemo.video.natives;

import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
import com.awesome.common.base.mvp.BaseActivity;
import com.awesome.common.constant.Constant;
import com.awesome.videodemo.R;
import java.io.File;

/**
 * VideoView播放
 */
public class VideoViewActivity extends BaseActivity {
    private File mFile;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_view);
        if (!hasPermission(Constant.WRITE_EXTERNAL_PERMISSION)) {
            requestPermission(Constant.WRITE_EXTERNAL_CODE, Constant.WRITE_EXTERNAL_PERMISSION);
        }
        mFile = new File("/storage/emulated/0/DCIM/Camera/TG-2022-06-22-230432884.mp4");
        videoViewMediaController();
    }


    private void videoViewMediaController() {
        VideoView videoView = findViewById(R.id.video_view);
        MediaController mediaController = new MediaController(this);
        videoView.setVideoPath(mFile.getAbsolutePath());
        videoView.setMediaController(mediaController);
        videoView.start();
    }
}